// 不能带有特殊字符
export const checkSpecialKey = (str: string): boolean => {
  let specialKey = "[`~!#$^&*()=|{}':;'\\[\\].<>/?~！#￥……&*（）——|{}【】‘；：”“'。，、？]‘'"
  for (let i = 0; i < str.length; i++) {
    if (specialKey.indexOf(str.substr(i, 1)) != -1) {
      return false
    }
  }
  return true
}
// 验证规则
export const customerNumberValidator = (rule: any, value: any, callback: any) => {
  if (!checkSpecialKey(value)) {
    console.log('🌈成功->信息', value)
    callback(new Error('不允许输入特殊字符'))
  } else {
    callback()
  }
}

// 日期格式校验
export const dateFormatCheck = (str: string): boolean => {
  let specialKey = /^(\d{4})-(\d{2})-(\d{2})$/
  if (!specialKey.test(str)) {
    return false
  } else {
    return true
  }
}
// 验证规则
export const dateFormatCheckValidator = (rule: any, value: any, callback: any) => {
  if (!dateFormatCheck(value)) {
    console.log('🌈成功->信息', value)
    callback(new Error('请输入正确的日期格式:XXXX(年)-XX(月)-XX(日)'))
  } else {
    callback()
  }
}
